<template>
  <div class="user">
    <button>隐藏</button>
    <p>用户信息展示:</p> {{$store.state.user.profile}}
    <button @click="testAjax">点击发送ajax</button>
    <span>用户姓名变更:{{$store.state.user.profile.name}}</span>
  </div>
</template>

<script>
import request from '@/utils/request.js'
// 使用Vuex中的数据步骤
// 1:导入useStore方法
import { useStore } from 'vuex'
export default {
  setup () {
    const store = useStore()
    console.log(store)
    setTimeout(() => {
      store.commit('user/setUserName', '李连杰')
      console.log('777')
    }, 6000)
    // 测试封装的axios函数
    const testAjax = async () => {
      // request('/category', 'GET', { id: 1 })
      const res = await request('/member/profile', 'GET', { id: 1 })
      console.log(res)
    }
    return {
      testAjax
    }
  }
}
</script>

<style lang="less" scoped>
</style>
